<template>
  <div class="register">
    <el-row display="margin-top:10px">
      <div><el-input v-model="userInput" placeholder="user" style="display:inline-table; width: 30%; float:left"></el-input></div>
        <div><el-input v-model="passwordInput" type="password" placeholder="password" style="display:inline-table; width: 30%; float:left"></el-input></div>
        <el-button type="primary" @click="user_register()" style="float:left; margin: 2px;">register</el-button>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'register',
  data () {
    return {
      userInput: '',
      passwordInput:'',
    }
  },
  methods: {
    user_register(){
      var ptomd5 = this.$md5(this.passwordInput)
      this.$axios
        .get(
          "http://127.0.0.1:8000/typetutor/login/?action=register&u=" +
            this.userInput +
            "&p=" +
            ptomd5
        )
        .then(res => {
          console.log(res)
          if (res.data.error_num == 0) {
            console.log(res.data.msg);
          } else if (res.data.error_num == 2) {
            console.log(res.data.msg)
          } else {
            this.$message.error("-------")
          }
        });
    },
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}

ul {
  list-style-type: none;
  padding: 0;
}

li {
  display: inline-block;
  margin: 0 10px;
}

a {
  color: #42b983;
}
</style>
